import request from '@/utils/request'
import type {
  User,
  UserInfo,
  UserQuery,
  UserList,
  HandlerUserDialogInfo
} from '@/types/user'
import type { ApiRes } from '@/types/data'

// 登录接口
export const login = (data: User) => {
  return request<ApiRes<{ token: string }>>({
    url: 'admin/login',
    method: 'POST',
    data
  })
}

// 获取当前用户信息接口
export const getUserInfo = () => {
  return request<ApiRes<UserInfo>>({
    url: 'admin/detail'
  })
}

// 获取用户信息列表接口
export const getUserList = (params: UserQuery) => {
  return request<ApiRes<UserList>>({
    url: 'admin/list',
    params
  })
}

// 用户新增
export const getAddUserInfo = (data: HandlerUserDialogInfo) => {
  return request({
    url: 'admin/add',
    method: 'POST',
    data
  })
}

// 用户修改信息
export const updateUserInfo = (data: HandlerUserDialogInfo) => {
  return request({
    url: 'admin/update',
    method: 'POST',
    data
  })
}

// 删除用户
export const deleteUser = (adminid: string) => {
  return request({
    url: 'admin/delete',
    method: 'POST',
    data:{adminid}
  })
}
